const express = require('express');
const app = express();
const port = 3000;

// 假设这是从数据库中获取的文章数据
const articles = [
  { id: 1, title: '如何学习JavaScript', keywords: ['JavaScript', '学习'] },
  { id: 2, title: 'Python编程入门', keywords: ['Python', '编程', '入门'] },
  // 更多文章...
];

// 搜索文章的路由
app.get('/search', (req, res) => {
  const keyword = req.query.keyword;
  const filteredArticles = articles.filter(article =>
    article.keywords.includes(keyword)
  );
  res.json(filteredArticles);
});

app.listen(port, () => {
  console.log(`Server listening at http://localhost:${port}`);
});
